#! /bin/bash
#SQOOP_HOME=/opt/cloudera/parcels/CDH-6.2.1-1.cdh6.2.1.p0.1425774/bin/sqoop
SQOOP_HOME=/usr/bin/sqoop
if [[ $1 == "" ]];then
   TD_DATE=`date -d '1 days ago' "+%Y-%m-%d"`
else
   TD_DATE=$1
fi
#学生打卡导入
sqoop import \
--connect jdbc:mysql://106.75.33.59:3306/teach \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select *,'${TD_DATE}' as dt from tbh_student_signin_record where 1=1 and  \$CONDITIONS" \
--hcatalog-database zxoe_ods \
--hcatalog-table ods_tbh_student_signin_record \
-m 1
wait

#学生请假导入
sqoop import \
--connect jdbc:mysql://106.75.33.59:3306/teach \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select *,'${TD_DATE}' as dt from student_leave_apply where 1=1 and  \$CONDITIONS" \
--hcatalog-database zxoe_ods \
--hcatalog-table ods_student_leave_apply \
-m 1
wait

#学生作息表
sqoop import \
--connect jdbc:mysql://106.75.33.59:3306/teach \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select *,'${TD_DATE}' as dt from tbh_class_time_table where 1=1 and  \$CONDITIONS" \
--hcatalog-database zxoe_ods \
--hcatalog-table ods_tbh_class_time_table \
-m 1
wait

#班级课程表
sqoop import \
--connect jdbc:mysql://106.75.33.59:3306/teach \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select *,'${TD_DATE}' as dt from course_table_upload_detail where 1=1 and  \$CONDITIONS" \
--hcatalog-database zxoe_ods \
--hcatalog-table ods_course_table_upload_detail \
-m 1
wait

#班级人数表
sqoop import \
--connect jdbc:mysql://106.75.33.59:3306/teach \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select *,'${TD_DATE}' as dt from class_studying_student_count where 1=1 and  \$CONDITIONS" \
--hcatalog-database zxoe_ods \
--hcatalog-table ods_class_studying_student_count \
-m 1
wait

#日历表
sqoop import \
--connect jdbc:mysql://106.75.33.59:3306/teach \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select * from calendar where 1=1 and  \$CONDITIONS" \
--hcatalog-database zxoe_ods \
--hcatalog-table ods_calendar \
-m 1
wait